home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
LOGIC Apps
/
Logic-APPLE_II_APPS.iso
/
mac
/
LOGIC Apple II 5.25" Library - ProDOS
/
PRO001.dsk
/
FIN
/
LOAN.INT.RATE.bas
< prev
next >
Wrap
BASIC Source File
|
2012-02-16
|
2KB
|
46 lines
10 PRINT "ANNUAL INTEREST RATE ON A LOAN"
20 PRINT
29 REM - STATEMENTS 30 TO 100 REQUEST USER INPUT
30 PRINT "REGULAR PAYMENT";
40 INPUT R
50 PRINT "TERM IN YEARS, MONTHS";
60 INPUT Y0,M
64 REM - CALCULATE YEARS FROM YEARS AND MONTHS
65 Y = (12 *Y0 +M)/12
70 PRINT "PRINCIPAL";
80 INPUT P
90 PRINT "NUMBER OF PAYMENTS PER YEAR";
100 INPUT N
109 REM - GUESS AN INTEREST RATE (10%) TO INITIATE TESTING
110 I = 10
119 REM - I2*LAST GUESS OR ESTIMATE ( START WITH 0 )
120 I2 = 0
129 REM - COMPUTE REGULAR PAYMENT USING GUESSED INTEREST RATE
130 R1 = (I *P/N)/(1 -1/((I/N +1) ^(N *Y)))
139 REM - ROUND OFF TO NEAREST CNET
140 R1 = INT(R1 *100 +.5)/100
149 REM - I3=NUMBER USED TO CLOSE IN ON INTEREST RATE
150 I3 = ABS(I -I2)/2
159 REM - SAVE THIS GUESS
160 I2 = I
168 REM - COMPARE COMPUTED PAYMENT (R1) TO INPUT PAYMENT (R);
169 REM - IF THEY'RE EQUAL, LAST RATE GUESSED=APPROXIMATE REG. PAYMENT
170 IF R1 = R THEN 230
180 IF R1 >R THEN 210
189 REM - R1<R, RATE MUST BE HIGHTER THAN LAST GUESS
190 I = I +I3
199 REM - RETEST WITH NEW GUESS
200 GOTO 130
209 REM R1>R, RATE MUST BE LOWER THAN LAST GUESS
210 I = I -I3
219 REM - RETEST WITH NEW GUESS
220 GOTO 130
229 REM - COMPUTE INTEREST TO PROPER PROPORTIONS, ROUND OFF, PRINT
230 I = (( INT((I *1000) *100 +.5))/100)/1000
240 PRINT "ANNUAL INTEREST RATE = ";I *100;"%"
250 PRINT
259 REM - RESTART OR END PROGRAM
260 PRINT "MORE DATA? (1=YES, 0=NO)";
270 INPUT X
280 IF X = 1 THEN 20
290 PRINT "<CTRL-D>RUN HELLO"